import datetime, sys 
import Global, Lexical, Parser, Semantics, Pragmatics

testDataPath = './Parser_Test_Data.txt'
#testDataErrorPath = './Parser_Test_Data_Error.txt'
outputPath = './output.txt'
if len(sys.argv) == 3 :
    testDataPath = sys.argv[1]
    outputPath = sys.argv[2];

testDataFile = open(testDataPath, 'r')
Global.outputFile = open(outputPath, 'w')

Global.outputFile.write('Name: Jian Li, Yanlin Han\nemail: jjli@clemson.edu, yanlinh@clemson.edu\nTime Stamp: '+datetime.datetime.now().strftime("%m-%d-%Y %H:%M:%S")+'\n\n')
for line in testDataFile:
    if Global.flag[1] == 1:
        Global.outputFile.write('Input line: '+line)
        Global.count_line += 1 
    Lexical.lexical(line)
    Parser.parser()
Parser.reduction()
Semantics.printGlobalSymbolTable()
Pragmatics.pragmatics()
Global.outputFile.close()
